package com.itheima.dao;

import com.itheima.pojo.Member;
import com.itheima.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

public interface OrderInforDao {
    @Select("select * from t_member where phoneNumber = #{tel}")
    Member selectMember(String telephone);

    @Select("select * from t_order where id = #{id} and orderDate = #{orderDate} and setmeal_id = #{setmealId}")
    List<Order> selectRepetition(@Param("id") Integer id,@Param("orderDate") Date orderDate,@Param("setmealId") String setmealId);

    //@Insert("insert into t_order values(null,#{memberId},#{orderDate},#{orderType},#{orderStatus},#{setmealId})")
    void add(Order order);

    //@Insert("insert into t_member(name,sex,phoneNumber,regTime) values(#{name},#{sex},#{phoneNumber},#{regTime}) ")
    void addMember(Member mem);

    @Select("select t.name member,o.orderDate orderDate,o.orderType orderType,s.name setmeal from t_order o,t_member t,t_setmeal s where o.member_id = t.id and o.setmeal_id = s.id and o.id = #{id}")
    Map findById(int id);

    List<Order> findAll();
}
